prepare('SELECT image FROM products WHERE product_code =:uid'); $stmt_select->execute(array(':uid'=>$_GET['delete_id'])); $imgRow=$stmt_select->fetch(PDO::FETCH_ASSOC); unlink("../img/".$imgRow['image']); // it will delete an actual record from db $stmt_delete = $DB_con->prepare('DELETE FROM products WHERE product_code =:uid'); $stmt_delete->bindParam(':uid',$_GET['delete_id']); $stmt_delete->execute(); header("Location: home.php"); } ?>